package com.harmay.center.monitor.controller;

import com.harmay.center.monitor.dto.CollectorDto;
import com.harmay.center.monitor.service.MetricBaseMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Zuper
 * @version 1.0
 * @date 2022/6/29 9:37
 * @description 用于http端发送的请求处理
 */
@RestController
@RequestMapping("/v1/collect")
public class CollectorController {

    @Autowired
    private MetricBaseMappingService service;

    @RequestMapping(value = "metric", method = RequestMethod.POST)
    public void metric(HttpServletRequest request, @RequestBody CollectorDto dto) {
        service.handleMetric(dto);
    }

    @RequestMapping(value = "metricWithUsers", method = RequestMethod.POST)
    public void metricWithUsers(HttpServletRequest request, @RequestBody CollectorDto dto) {
        service.handleMetricWithUsers(dto);
    }
}
